<!DOCTYPE html>
<html>
  <head>
    <title>Listing 14.1</title>
    <meta charset="utf-8">
    <script type="text/javascript" src="../scripts/assert.js"></script>
    <link href="../styles/assert.css" rel="stylesheet" type="text/css">
  </head>
  <body>
    <script type="text/javascript">

      var tags = /^(abbr|br|col|img|input|link|meta|param|hr|area|embed)$/i;

      function convert(html) {
        return html.replace(/(<(\w+)[^>]*?)\/>/g, function (all, front, tag) {
          return tags.test(tag) ?
              all :
              front + "></" + tag + ">";
        });
      }

      assert(convert("<a/>") === "<a></a>", "Check anchor conversion.");
      assert(convert("<hr/>") === "<hr/>", "Check hr conversion.");

    </script>
  </body>
</html>
